import java.util.HashSet;
import java.util.Set;

public class Leet940 {
    public static void main(String[] args) {
        System.out.println(distinctSubseqII("abc"));
    }
    static public int distinctSubseqII(String S) {
        Set<String> set = new HashSet<>();
        for (int i = 0; i <= S.length(); i++) {
            for (int j = i+1; j <= S.length(); j++) {
                set.add(S.substring(i,j));
            }
        }
        return set.size();
    }
}
